module=$1
profile=${2:-"test"}
echo "deploy $profile ...."

package_path=/data/services/deploy/kylin-mall
service_path=/data/services/kylin-${module}
service_file=kylin-${module}.tar.gz

init(){
	echo "delploy $module oauth"
	mkdir -p $service_path
}

reload(){
	sh $service_path/service.sh stop $profile
	rm -Rf $service_path/*

	echo "copy tar file to $target_path"
	cp -f $package_path/$service_file $service_path

	tar -xvf $package_path/$service_file -C $service_path

	chmod 777 $service_path/* -Rf
	sh $service_path/service.sh start $profile

}

case x$module in
    xadmin|xh5app)
        case $profile in     
		test|youxuan|yanxuan|jinmao|nandu)
 			init
			reload
        		echo "deploy success!"
          		exit
			;;
             *)
                ;;
        esac
	;;
    *)
    echo "build [admin | h5app]  [test | youxuan | jinmao ]"
    exit
    ;;
esac

